import {createRouter, createWebHistory} from 'vue-router';
import Framework from "./components/layout/framework.vue";
import NotFound from './components/layout/error.vue';

const menu = [
    {
        name: '首页', icon: "DocumentCopy",
        path: 'index',
        component: () => import('./components/home/index.vue'),
    },
    {
        name: '订单管理', icon: "IconMenu",
        path: '/',
        children: [
            {
                name: '订单列表', icon: "Odometer",
                path: 'orderList',
                component: () => import('./components/order/orderList.vue'),
            },
            {
                name: '订单商品列表', icon: "Discount",
                path: 'orderUnionList',
                component: () => import('./components/order/orderUnionList.vue'),
            },
            {
                name: '配件统计列表', icon: "Service",
                path: 'orderPartsStatisticsList',
                component: () => import('./components/order/orderPartsStatisticsList.vue'),
            },
        ]
    },
    {
        name: '会员管理', icon: "User",
        path: '/',
        children: [
            {
                name: '会员列表', icon: "User",
                path: 'memberList',
                component: () => import('./components/member/memberList.vue'),
            },
        ]
    },
    {
        name: '商品管理', icon: "Goods",
        path: '/',
        children: [
            {
                name: '产品品牌', icon: "ShoppingBag",
                path: 'goodsBrandList',
                component: () => import('./components/goods/brandList.vue'),
            },
            {
                name: '产品颜色', icon: "Brush",
                path: 'goodsColorList',
                component: () => import('./components/goods/colorList.vue'),
            },
            {
                name: '产品规格', icon: "Coin",
                path: 'goodsSpecList',
                component: () => import('./components/goods/specList.vue'),
            },
            {
                name: '配件分类', icon: "Refrigerator",
                path: 'partsCategoryList',
                component: () => import('./components/parts/categoryList.vue'),
            },
            {
                name: '配件管理', icon: "QuartzWatch",
                path: 'partsList',
                component: () => import('./components/parts/partsList.vue'),
            },

            {
                name: '进货（开发中）', icon: "Iphone",
                path: 'purchase',
                component: () => import('./components/goods/purchase.vue'),
            },
        ]
    },
    {
        name: '库存管理', icon: "Film",
        path: '/',
        children: [
            {
                name: '配件库存', icon: "QuartzWatch",
                path: 'stockPartsList',
                component: () => import('./components/supplier/supplierList.vue'),
            },
            {
                name: '进货单', icon: "Handbag",
                path: 'inSheetList',
                component: () => import('./components/stock/InSheetList.vue'),
            },
        ]
    },
    {
        name: '供应商相关', icon: "Bicycle",
        path: '/',
        children: [
            {
                name: '供应商管理', icon: "Bicycle",
                path: 'supplierList',
                component: () => import('./components/supplier/supplierList.vue'),
            },
            {
                name: '进货款结算', icon: "Handbag",
                path: 'listWithInSheet',
                component: () => import('./components/supplier/listWithInSheet.vue'),
            },
            {
                name: '退货款结算', icon: "Handbag",
                path: 'listWithBackSheet',
                component: () => import('./components/supplier/listWithBackSheet.vue'),
            },
        ]
    },

    {
        name: '资金管理', icon: "Wallet",
        path: '/',
        children: [
            {
                name: '资金总览', icon: "Stopwatch",
                path: 'walletIndex',
                component: () => import('./components/wallet/index.vue'),
            },
        ]
    },
    {
        name: '展示管理', icon: "Wallet",
        path: '/',
        children: [
            {
                name: '文件列表', icon: "Stopwatch",
                path: 'expoList',
                component: () => import('./components/expo/expoList.vue'),
            },
        ]
    },
]
const routes = [
    {
        path: '/',
        component: Framework,
        meta: {
            keepAlive: true
        },
        children: [
            {
                path: '/',
                redirect: '/index',
            },

            ...menu
        ]
    },
    {
        name: 'login',
        path: '/login',
        component: () => import('./components/layout/login.vue'),
    },
    {
        name: 'expo',
        path: '/show',
        component: () => import('./components/expo/index.vue'),
    },
    {
        name: '404',
        path: "/:pathMatch(.*)",
        component: NotFound,
    },
];

const router = createRouter({
    routes,
    history: createWebHistory(),
});
router.beforeEach((to, from, next) => {
    // const title = to.meta && to.meta.title;
    // if (title) {
    //   document.title = title;
    // }
    // if (to.meta.requireLogin) {
    //   if (!window.localStorage.getItem("token")) {
    //     next({
    //       name: "mine",
    //       query: { redirect: to.fullPath }
    //     })
    //   }
    // }
    // if (to.meta.requireAuth) {
    //   if (!window.localStorage.getItem("auth")) {
    //     next({
    //       name: "admin-login",
    //       query: { redirect: to.fullPath }
    //     })
    //   }
    // }
    next();
});
export {router, menu};

